home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / emulation / amoricv0_9 / src / runtime_xxx.asm < prev    next >
Assembly Source File  |  1995-10-29  |  5KB  |  246 lines

  1. ; *** ORIC Emulator. Amiga Version 680x0 ***
  2. ; *** Copyright 1995/96 JF FABRE ***
  3. ; *** Main program ***
  4.  
  5. ; D0   : **scratch**
  6. ; d1.b : A
  7. ; d2.b : X
  8. ; d3.b : Y
  9. ; d4.b : P
  10. ; d5.b : S
  11. ; D6   : **scratch**
  12. ; D7   : **scratch**
  13.  
  14. ; a0.l : Mem Ptr
  15. ; a1.l : Mem Ptr + $304
  16. ; a2.l : Functable pour les instructions
  17. ; a3.l : Pointeur sur diverses tables
  18. ; a4.l : PC+Base Adr
  19. ; a5.l : **Scratch**
  20. ; a6.l : **Scratch**
  21.  
  22.         XDEF    _RunOric        ; C
  23.         XDEF    _ReturnToMonitor
  24.     XDEF    _StepOric        ; C
  25.     XDEF    _HandleCtrl
  26.     XDEF    _MainLoop
  27.     XDEF    _MainLoopReload
  28.  
  29.     XDEF    _BreakReason
  30.                
  31.         XREF    _InitKbTableOnce
  32.     XREF    _InitKbTable
  33.     XREF    _InitFonctions
  34.         XREF    _IRQ
  35.         XREF    _RegistersToMem
  36.         XREF    _MemToRegisters
  37.     XREF    _RefreshScreen
  38.     XREF    _RewindTapeLoadAsm
  39.     XREF    _GotoTextMode
  40.  
  41.     XREF    _RefreshScr
  42.     XREF    _ShowHelp
  43.     XREF    _InitSound
  44.     XREF    _StopSound
  45.  
  46.     XREF    _SoundOn
  47.     XREF    _CtrlKeyPressed
  48.  
  49.     XREF    _NextJump
  50.  
  51.     XREF    _UserLoadT1
  52.     XREF    _UserLoadT2
  53.  
  54.         XREF    _M
  55.         XREF    _A
  56.         XREF    _X
  57.         XREF    _Y
  58.         XREF    _S
  59.         XREF    _P
  60.         XREF    _PC
  61.  
  62. NB_CYCLE = 4
  63.    
  64.         include "my_defs.i"
  65.     include    "libs.i"
  66.     include    "my_macros.asm"
  67.  
  68.         
  69. ; *** Programme principal ***
  70.  
  71.     
  72. _RunOric:            ; Point d'entree du C
  73. @RunOric:
  74.         STORE_REGS
  75.     move.l    AbsExecbase,A6
  76.     CALLLIB    _LVOForbid
  77.     jsr    _InitSound
  78.         jsr     _MemToRegisters
  79. _MainLoopReload:
  80.     move.l    #_MainLoop,_NextJump
  81. _MainLoop:
  82.     ;*** Horloge Timer 1
  83.  
  84. Timer1:
  85.     subq.b    #NB_CYCLE,(A1)    ; 3 = Nb de Cycles moyen par instruction
  86.     bcs.b    Dec305
  87. Timer2:
  88.     subq.b    #NB_CYCLE,4(A1)        ; 4 = Nb de Cycles moyen par instruction
  89.     bcs.b    Dec309
  90.  
  91. ProcessInst:
  92.     moveq.l    #0,D6
  93.     move.b    (A4)+,D6    ; Incrementation de 1 de A4 = PC++    
  94.     MACRO_PROCESSINST
  95.     jmp    (A6)
  96.  
  97. InvertPB7:
  98.     bchg    #7,-4(A1)
  99.     bra.b    T1Int_Suite
  100.  
  101. Dec305:
  102.     DEC_TxH    1
  103.     subq.b    #1,1(A1)
  104.     bne.b    Timer2
  105.  
  106. T1Int:
  107.     RELOAD_TIMER1        ; Rechargement des cellules
  108.  
  109.     btst    #6,$7(A1)    ; Test du bit 6 de $30B -> Si 1 : Interruptions Continues
  110.     bne.b    T1DoInt        ; Si 0 : Interruptions uniquement lors d'un load
  111.  
  112.     btst    #7,$7(A1)    ; Test du bit 7 de $30B -> Si 1 : Inversion de PB7
  113.     bne.b    InvertPB7
  114. T1Int_Suite:
  115.     tst.b    _UserLoadT1
  116.     beq.b    Timer2
  117.     clr.b    _UserLoadT1
  118.  
  119. T1DoInt:
  120.  
  121.     moveq    #6,D6
  122.     bset    D6,$9(A1)    ; Met le bit 6 de $30D a 1
  123.     btst    D6,$A(A1)
  124.     beq.b    Timer2        ; IT masquee -> Ne fait rien
  125.     TST_PB    I_BIT
  126.     bne.b    Timer2        ; Interruptions masquees : Ne fait rien
  127.     CLR_PB    B_BIT
  128.     jmp    _IRQ        ; Saut a l'interruption IRQ
  129.  
  130.  
  131. Dec309:
  132.     DEC_TxH    2
  133.     subq.b    #1,5(A1)
  134.     bne.b    ProcessInst
  135.  
  136. T2Int:
  137.     btst    #5,$7(A1)    ; 30B ACR
  138.     bne.b    ProcessInst    ; Countdown pulse pas implémenté
  139.     tst.b    _UserLoadT2
  140.     beq.b    ProcessInst
  141.     clr.b    _UserLoadT2
  142.  
  143.     moveq    #5,D6
  144.     bset    D6,$9(A1)    ; Met le bit 5 de $30D a 1
  145.     btst    D6,$A(A1)
  146.     beq.b    ProcessInst    ; Masque = 0 -> Interruption masquee
  147.     TST_PB    I_BIT
  148.     bne.b    ProcessInst    ; Interruptions masquees : Ne fait rien
  149.     CLR_PB    B_BIT
  150.     jmp    _IRQ        ; Saut a l'interruption IRQ
  151.     
  152.  
  153. _StepOric:            ; Point d'entree du C
  154.     STORE_REGS
  155.     jsr    _MemToRegisters
  156.     move.l    #_ReturnToMonitor,_NextJump
  157.     move.b    #STEP_COMMAND,_BreakReason
  158.     bra    _MainLoop    ; Ensuite, ca reviendra a _ReturnToMonitor
  159.  
  160.  
  161. _ReturnToMonitor:    
  162.     
  163.     jsr    _RegistersToMem
  164.     RESTORE_REGS
  165.         
  166.     moveq.l    #0,D0
  167.         move.b  _BreakReason(PC),D0
  168.     move.l    AbsExecbase,A6
  169.     CALLLIB    _LVOPermit
  170.         rts     ; Retour au C (moniteur)
  171.         
  172. BreakReq:
  173.     move.b    #USER_BREAK,_BreakReason
  174.     bra.b    _ReturnToMonitor
  175.  
  176. ChtLoad:
  177.     move.b    #CHANGE_TAPE,_BreakReason
  178.     bra.b    _ReturnToMonitor
  179.  
  180. _HandleCtrl:
  181.     move.b    _CtrlKeyPressed,D6
  182.     clr.b    _CtrlKeyPressed
  183.     andi.w    #$FF,D6
  184.     subq.w    #1,D6
  185.     lea    ControlTable(PC),A6
  186.     MACRO_HANDLECTRL
  187.     jmp    (A6)
  188.  
  189. WarmReset:
  190.     jsr    _InitKbTable
  191.     clr.b    -4(A1)    ; Port B a 0
  192.     moveq.l    #0,D6
  193.     moveq.l    #0,D6
  194.     move.w    #$FFFA,D6
  195.     move.b    1(A0,D6.L),D0
  196.     lsl.w    #8,D0
  197.     move.b    (A0,D6.L),D0
  198.     move.l    A0,A4
  199.     add.l    D0,A4
  200.     bra    _MainLoopReload
  201.  
  202. ColdReset:
  203.     jsr    _StopSound
  204.     jsr    _InitKbTable
  205.     clr.b    -4(A1)
  206.     moveq.l    #4,D4    ; Interrupts off
  207.     moveq.l    #0,D6
  208.     moveq.l    #0,D0
  209.     move.w    #$FFFC,D6
  210.     move.b    1(A0,D6.L),D0
  211.     lsl.w    #8,D0
  212.     move.b    (A0,D6.L),D0
  213.     move.l    A0,A4
  214.     add.l    D0,A4
  215.     jsr    _GotoTextMode
  216.     bra    _MainLoopReload
  217.  
  218.  
  219. HotRewind:
  220.     jsr    _RewindTapeLoadAsm
  221.     bra    _MainLoopReload
  222.     
  223. ToggleSound:
  224.     tst.b    _SoundOn
  225.     beq.b    SoundWasOff
  226.     clr.b    _SoundOn
  227.     jsr    _StopSound
  228.     bra    _MainLoopReload
  229.  
  230. SoundWasOff:
  231.     st.b    _SoundOn
  232.     bra    _MainLoopReload
  233.     
  234.  
  235.  
  236. _BreakReason:
  237.     dc.b    0
  238.     even
  239.  
  240. ControlTable:
  241.     dc.l    WarmReset,_RefreshScr,ChtLoad,_MainLoopReload,ColdReset
  242.     dc.l    ToggleSound,HotRewind,_MainLoopReload,_MainLoopReload,BreakReq
  243.     dc.l    _MainLoopReload,_MainLoopReload,_MainLoopReload
  244.     dc.l    _MainLoopReload,_MainLoopReload,_ShowHelp
  245.  
  246.